package com.example.dell.wisdom_farm;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_anniu1,btn_anniu2;
    private EditText editText1,editText2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        btn_anniu1=(Button)findViewById(R.id.login_button_log);
        btn_anniu2=(Button)findViewById(R.id.button_zhuce);
        editText1=(EditText)findViewById(R.id.login_editText1_log);
        editText2=(EditText)findViewById(R.id.login_editText2_log);

        btn_anniu1.setOnClickListener(this);
        btn_anniu2.setOnClickListener(this);
    }
    @Override
    public void onClick(View v){
        switch (v.getId()){
            case R.id.login_button_log:
                String context1=editText1.getText().toString();
                String context2=editText2.getText().toString();
                if(context1.isEmpty()) {
                    Toast.makeText(this, "登录账号不能为空", Toast.LENGTH_LONG).show();
                }
                else if(context2.isEmpty()) {
                    Toast.makeText(this, "登录密码不能为空", Toast.LENGTH_LONG).show();
                }
                else{
                    Intent intent=new Intent(LoginActivity.this,IndexActivity.class);
                    startActivity(intent);
                    finish();
                }
                break;

            case R.id.button_zhuce:
                Intent intent = new Intent( LoginActivity.this,ZhuCeActivity.class);
                startActivity(intent);
                finish();
                break;
        }
    }

}
